import BaseUtil from '@/BaseUtil';
import { OrderId } from '@/globals/order';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 生命汲取
 **/
export default class SS_SeekLife extends AbilityBase {
    static instance: SS_SeekLife;
    constructor(id: string = 'Asmq') {
        super(id);
        SS_SeekLife.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BaseUtil.onTimer(0.5, (c) => {
            // drain
            if (GetUnitCurrentOrder(source) == OrderId.Drain) {
                let lv = this.getAbilityLevel(source);
                let dmg = 30 * lv + UnitCommon.取法强(source) * (0.7 + 0.35 * lv);
                if (IsUnitEnemy(target, GetOwningPlayer(source))) {
                    DamageSystemInstance.applyDarkDamage(target, source, dmg / 2, this.id);
                    DamageSystemInstance.applyHeal(source, source, dmg / 2, this.id);
                } else {
                    DamageSystemInstance.applyDarkDamage(source, source, dmg / 2, this.id);
                    DamageSystemInstance.applyHeal(target, source, dmg / 2, this.id);
                }
            } else {
                return false;
            }
            return c < 11;
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
